<!--{template ADMIN_DIRECTORY/tpl/admin_header}-->
<div class="page_title">
    	<h1>{$_lang['user_manage']}</h1>
        <div class="tool">
            <a href="index.php?do=user&view=list" >{$_lang['user_manage']}</a>
            <a href="index.php?do=user&view=add">{if $edituid}{$_lang['edit']}{else}{$_lang['add']}{/if}{$_lang['user']}</a>
    		<a href="index.php?do=user&view=charge" class="here">{$_lang['charge']}</a>
		</div>
    </div>
		<div class="box post">
        <div class="tabcon">
        	<div class="title"><h2>{$_lang['charge']}</h2></div>
            <div class="detail">
               <form action="#" method="post" name="frm_cash" id="frm_cash">
               		<input type="hidden" name="formhash" id="formhash" value="{FORMHASH}">
                    <input type="hidden" name="view" value="{$view}">
					<input type="hidden" name="valid" id="valid">
					<input type="hidden" name="maxCash" id="maxCash">
					<input type="hidden" name="maxCredit" id="maxCredit">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tbody>
                      <tr>
                        <th scope="row" width='100'>{$_lang['uid']}{$_lang['zh_mh']}</th>
                        <td>
                              <select name="user_type" id="user_type">
                        		<option value="1">UID</option>
                        		<option value="2">用户名</option>
                        	</select>
                       		<input type="text" class="txt" style=" width:260px;" name="user"
								id="txt_user" title="{$_lang['please_input_limit']}"
								limit="required:true" msgArea="txt_user_msg"
							  	msg="{$_lang['username_uid_can_not_null']}"/>
							<b style="color:red"> *</b><span id="txt_user_msg"></span>{$_lang['user_tips']}
							<a class="button dbl_target" href="javascript:void(0);" onclick="validUser();">
								<span class="chat icon"></span>
								{$_lang['valid']}
							</a>
							<div class="box tip clearfix p_relative" style="width:310px;display:none;" id="man_tips">
						    	<div class="title"><h2>{$_lang['account_info']}</h2></div>
						        <div class="detail pad10">
						        	<span class="pad10" id="ucash"></span></br>

						        </div>
						</div>
					   </td>
                      </tr>
                      <tr>
                        <th scope="row">{$_lang['exisits_cash']}{$_lang['zh_mh']}</th>
                        <td>
                        	<select name="cash_type" id="cash_type">
                        		<option value="1">$_lang['recharge']</option>
                        		<option value="0">$_lang['deduct']</option>
                        	</select>
                        	 <input type="text" class="txt" style="width:260px;"
							  name="cash" id="cash"
							  limit="type:float;between:0-999999999999"
							  title="{$_lang['please_input_cash']}..."
							  msg="{$_lang['cash_can_not_null']}"
						      msgArea="cash_msg"  class="input_t"/>
							 <span id="cash_msg"></span>
						</td>
                      </tr>
                      <tr>
                      	<th>$_lang['charge_reason']</th>
                      	<td>
                      		<textarea name="charge_reason" rows="8" cols="50"></textarea>
                      	</td>
                      </tr>
                      <tr>
                        <th scope="row">&nbsp;</th>
                        <td>
                            <div class="clearfix padt10">
                            	<input type="hidden" name="is_submit" value="1">
                                <button class="positive primary pill button" type="button" value="{$_lang['submit']}" onclick="frm_check();"><span class="check icon"></span>{$_lang['submit']}</button>

                            </div>
                        </td>
                      </tr>
					  </tbody>
                    </table>
                </form>
        </div>


    </div>
 <script type="text/javascript">
 	function validUser(){
 		var t = $("#user_type").val();
		var v   = $("#txt_user").val();
		if(v<1||$("#txt_user_msg").hasClass('valid_error')){
			art.dialog.tips("{$_lang['username_uid_can_not_null']}",1.5);
			$("#man_tips").hide('slow');
			$("#valid").val(0);
		}else{
			var url = "index.php?do=user&view=charge";
			$.getJSON(url,{check_uid:v,'t':t},function(json){
				if(json.status==1){
					$("#ucash").html("{$_lang['usefull_balance']}"+json.data.balance+"{$_lang['yuan']}");

					$("#man_tips").show('slow');
					$("#maxCash").val(json.data.balance);
					$("#valid").val(1);
				}else{
					art.dialog.tips(json.msg,1.5);
					$("#man_tips").hide('slow');
					$("#txt_user").focus();
					$("#valid").val(0);
				}
			});
		}
	}
 	function frm_check(){
		var i =  checkForm(document.getElementById("frm_cash"),false);
			if(i){
				if($("#valid").val()==1){
					var t 			= true;
					var cash_type = $("#cash_type").val();
					var maxCash 	= $("#maxCash").val();
					var ca = parseFloat($("#cash").val()).toFixed(2);
						isNaN(ca)?ca=0:'';
					var cr = parseFloat($("#credit").val()).toFixed(2);
						isNaN(cr)?cr=0:'';
						if(ca<-maxCash){
							art.dialog.alert("$_lang['user_deduct_limit'] "+maxCash+" {$_lang['yuan']}");
							t=false;
						}
						if(t===true){
							var content = '';
							if(cash_type == 1){
									content+="充值现金"+ca+"元;</br>";
							}else{
									content+="扣除现金"+Math.abs(ca)+"元;</br>"
							}
							art.dialog({
								title: "{$_lang['operate_tips']}",
								content: content,
								icon: 'succeed',
								yesFn: function(){$("#frm_cash").submit();},
								noFn :function(){this.close();return false;}
							});
						}
				}else{
					art.dialog.tips("{$_lang['pass_validation']}",1.5);
				}
			}
	}
 </script>
</div>
<!--{template ADMIN_DIRECTORY/tpl/admin_footer}-->
